package org.example03.mapper;

import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;
import org.example03.po.OrderDetail;
import org.example03.po.Product;

import java.util.List;

public interface OrderDetailMapper {
    @Results({
            @Result(column = "product_id",property = "productId"),
            @Result(property = "product",javaType = Product.class,
                    column = "product_id",
                    one = @One(select = "org.example03.mapper.ProductMapper.getProductById",fetchType = FetchType.LAZY))
    })
    @Select("select * from mybatis02.order_detail where order_id = #{orderId}")
    List<OrderDetail> getOrderDetailByOrderId();
}
